#ifndef __SpellCore__
#define __SpellCore__
#if _MSC_VER > 1000
#pragma once
#endif

#ifdef __cplusplus
extern "C" {
#endif

#define SCAPI __stdcall

typedef int            BOOL;
typedef const wchar_t* LPCWSTR;
typedef wchar_t*       LPWSTR;
typedef unsigned int   UINT;
typedef void*          HSCCHECKER;
typedef void*          HSCSUGGESTIONLIST;

#if defined(SCDLL)
#define SCAPIDECL  __declspec(dllexport)
#else
#define SCAPIDECL
#endif

// For every successful call to CreateSpellChecker, a matching call to FreeSpellChecker must be made
// Returns NULL if error occurs (can't connect to COM, szWritingSystemId is NULL or empty)
SCAPIDECL HSCCHECKER SCAPI CreateSpellChecker(LPCWSTR szWritingSystemId);
// if handle is null, ignores 
SCAPIDECL void SCAPI FreeSpellChecker(HSCCHECKER hChecker);

// Does this spell checker have any engines that can check spelling?
SCAPIDECL BOOL SCAPI CanCheckSpelling(HSCCHECKER hChecker);

SCAPIDECL void SCAPI AddGoodWord(HSCCHECKER hChecker, LPCWSTR strWord, UINT cchSize);

enum CheckingResult
{
    // no comment
    CheckingResultUnknown,
    // fails a structural rule
    CheckingResultStructurallyUnsound,
    // for sure ok
    CheckingResultGood,
    // Good but user wants it checked in context(ambiguous)
    CheckingResultVerify,
    // for sure bad
    CheckingResultBad
};

// if strWord is NULL or cchSize is 0, returns CheckingResultUnknown
SCAPIDECL enum CheckingResult SCAPI GetWordStatus(HSCCHECKER hChecker, LPCWSTR strWord, UINT cchSize);

typedef struct tag_SimilarityCheckResult{
  LPCWSTR szWord;
  int     score;
} SIMILARITY_CHECK_RESULT;

// Every Successful call to GetSuggestions must be followed by a call to FreeSuggestions
SCAPIDECL HSCSUGGESTIONLIST SCAPI GetSuggestions(HSCCHECKER hChecker, LPCWSTR strWord, UINT cchSize);
SCAPIDECL void SCAPI FreeSuggestions(HSCSUGGESTIONLIST hSuggestions);

// returns false when there are no more suggestions
// suggestions that are longer than the supplied buffer are skipped
SCAPIDECL BOOL SCAPI GetNextSuggestion(HSCSUGGESTIONLIST hSuggestions, LPWSTR strBuffer, UINT cchBuffer, long* score);

#ifdef __cplusplus
}
#endif
#endif
